
<style>
    #device_default_div label {
        width: 150px;
        background-color: #dddddd;
    }

    #device_default_div div.layui-form-item {
        margin-bottom: 5px;
    }

    #device_default_div fieldset {
        padding-bottom: 2px;
    }

    #device_default_div div.layui-tab-content {
        height: 401px;
    }

    .selectUp .layui-form-select dl {
        top: auto;
        bottom: 36px;
    }
</style>
<div class="layui-form layuimini-form  layui-form-pane" id="device_default_div" lay-filter="device_default_div_filter">
    <div class="layui-panel" style="height:450px;">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this"> 系统设置</li>
                <li> 门禁设置</li>
                <li> 人脸识别</li>
                <li> 网络参数</li>
                <li> 其他</li>
            </ul>

            <div class="layui-tab-content">
                <!-- 系统设置 -->
                <div class="layui-tab-item layui-show" id="device_Update_Page1">
                    <fieldset class="table-search-fieldset">
                        <legend> 设备身份</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 设备SN</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="16" 
                                               lay-verify="required" placeholder="请输入设备SN" lay-reqText="请输入设备SN"
                                               name="deviceID" autocomplete="off" class="layui-input"
                                               tipShow="1" tipMsg="设备SN由16个字符组成,必填">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 制造商</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="50" name="parameterManufacturer" autocomplete="off" class="layui-input"
                                               tipShow="1" tipMsg="制造商信息 最长50个字符,可为空">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 网址</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="50" name="parameterWebsite" autocomplete="off" class="layui-input"
                                               tipShow="1" tipMsg="制造商网址信息 最长50个字符,可为空">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 生产日期</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="20" name="parameterProductionDate" autocomplete="off" class="layui-input"
                                               lay-verify="required" placeholder="请输入生产日期"  lay-reqText="请输入生产日期"
                                               tipShow="1" tipMsg="设备生产日期 必填">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 公司名称</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="20" name="parameterCompanyName" autocomplete="off" class="layui-input"
                                               tipShow="1" tipMsg="公司名称 最长20个字符,可为空">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 菜单密码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="8" name="parameterLoginPassword" autocomplete="off" class="layui-input"
                                               tipShow="1" tipMsg="菜单密码 由4-8位数字组成<br/>仅支持数字，可为空">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend>外设</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">补光灯</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterLightSwitch" required lay-verify="">
                                            <option value="0" selected>常闭</option>
                                            <option value="1">常开</option>
                                            <option value="2">自动</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 曝光设置</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="3" min="-3" name="parameterExposure" autocomplete="off" class="layui-input"
                                               lay-verify="required" placeholder="请输入曝光设置" lay-reqText="请输入曝光设置"
                                               tipShow="1" tipMsg="曝光设置 取值范围 -3 -- 3,整数，必填">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 红外图像</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterIR" lay-skin="switch" lay-text="开启|关闭" unchecked value="1">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 声音及文字</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 音量</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="10" min="1"  maxlength="2" name="parameterVolume" autocomplete="off" class="layui-input"
                                                lay-verify="required" placeholder="请输入音量" lay-reqText="请输入音量"
                                                tipShow="1" tipMsg="音量大小 取值范围 0 -- 10，必填">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 屏幕亮度</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="10" min="1" required maxlength="2" name="parameterBrightness" autocomplete="off" class="layui-input"
                                                lay-verify="required" placeholder="请输入屏幕亮度" lay-reqText="请输入屏幕亮度"
                                                tipShow="1" tipMsg="屏幕亮度 取值范围 1 -- 10，必填">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 语言</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterLanguageChoose" required lay-verify="">
                                            <option value="0" selected>中文</option>
                                            <option value="1">英文</option>
                                            <option value="2">繁体</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 语音播报</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterVoiceMode" required lay-verify="">
                                            <option value="0">不播报</option>
                                            <option value="1">播放名字</option>
                                            <option value="2">播放问候语</option>
                                            <option value="3" selected>播放名字和问候语</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 问候语</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterGrettings" required lay-verify="">
                                            <option value="0" selected>请通行</option>
                                            <option value="1">欢迎光临</option>
                                            <option value="2">时间问候语</option>
                                            <option value="3">消费登记成功</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 陌生人语音</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterStrangerVoice" required lay-verify="">
                                            <option value="0">不播报</option>
                                            <option value="1">播报假体</option>
                                            <option value="2" selected>播报陌生人</option>
                                            <option value="3">播报假体和陌生人</option>
                                        </select>

                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>


                </div>
                <!-- 门禁设置 -->
                <div class="layui-tab-item" id="device_Update_Page2">

                    <fieldset class="table-search-fieldset">
                        <legend> 鉴权参数</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 出入类型</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="parameterAccessType" value="0" title="入门" checked>
                                        <input type="radio" name="parameterAccessType" value="1" title="出门">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 免验证开门</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterLaissezSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 识别间隔（秒）</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="65535" min="0" name="parameterRecgInterval" autocomplete="off" class="layui-input"
                                                lay-verify="required" placeholder="请输入识别间隔" lay-reqText="请输入识别间隔时间"
                                                tipShow="1" tipMsg="识别间隔时间，必填<br/> 取值范围 0 -- 65535(s)，单位：秒">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">保存重复记录</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterIntervalRecoSwitch" lay-skin="switch" lay-text="保存|丢弃" unchecked value="1">
                                    </div>
                                </div>
                            </div>

                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 输入输出</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> WG格式</label>
                                    <div id="divparameterWgFormat" class="layui-input-inline" style="padding-right: 1px; margin-right: 1px;">
                                        <input type="radio" name="parameterWgFormat" value="26" title="26">
                                        <input type="radio" name="parameterWgFormat" value="34" title="34" checked>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 开门保持(秒)</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="65535" min="0" name="parameterKeepOpenDoor" autocomplete="off" class="layui-input"
                                                lay-verify="required" placeholder="请输入开门保持" lay-reqText="请输入开门保持时间"
                                                tipShow="1" tipMsg="开门保持时间，必填<br/>识别后继电器输出的时间<br/> 取值范围 0 -- 65535(s)，单位:秒">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 报警</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 门磁报警</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterDoorAlarmSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 超时报警</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterDoorLongOpenAlarmSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 开门超时(秒)</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="255" min="5" name="parameterDoorSensorDelay" autocomplete="off" class="layui-input"
                                                lay-verify="required" placeholder="请输入开门超时" lay-reqText="请输入开门超时时间"
                                                tipShow="1" tipMsg="开门超时时间，必填<br/>启用【超时报警】功能后，门打开超过此时间后就会报警<br/>取值范围 5 -- 255(s)，单位：秒">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>

                </div>

                <!-- 人脸识别 -->
                <div class="layui-tab-item" id="device_Update_Page3">
                    <fieldset class="table-search-fieldset">
                        <legend> 人脸检测</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">



                                <div class="layui-inline">
                                    <label class="layui-form-label"> 识别距离</label>
                                    <div class="layui-input-inline">
                                        <select name="parameterDistance" required lay-verify="">
                                            <option value="1" selected>远</option>
                                            <option value="2">中</option>
                                            <option value="3">近</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label"> 识别阈值 </label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="99" min="1" name="parameterFaceThreshold" autocomplete="off" class="layui-input"
                                               lay-verify="required" placeholder="请输入人脸识别阈值" lay-reqText="请输入人脸识别阈值"
                                               tipShow="1" tipMsg="人脸识别阈值，必填<br/> 取值范围 1 -- 99">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label"> 活体检测</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterPreview" lay-skin="switch" lay-text="启用|禁用" checked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 活体阈值 </label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="10" min="1" name="parameterFaceIRThreshold" autocomplete="off" class="layui-input"
                                                lay-verify="required" placeholder="请输入人脸活体检测阈值" lay-reqText="请输入人脸活体检测阈值"
                                                tipShow="1" tipMsg="人脸活体检测阈值，必填<br/> 取值范围 1 -- 10">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 口罩检测</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">口罩检测</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterMask" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 口罩阈值</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="99" min="1" name="parameterMaskThreshold" autocomplete="off" class="layui-input"
                                                lay-verify="required" placeholder="请输入口罩检测阈值" lay-reqText="请输入口罩检测阈值"
                                                tipShow="1" tipMsg="口罩检测阈值， 取值范围 1 -- 99，必填">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 体温检测</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">体温检测</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterTempSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">温度补偿</label>
                                    <div class="layui-input-inline">
                                        <input type="number" min="-1.0" max="1.0"  step="0.1"  name="parameterCompensate" autocomplete="off" class="layui-input"
                                               lay-verify="required" placeholder="请输入温度补偿值" lay-reqText="请输入温度补偿值"
                                               tipShow="1" tipMsg="温度补偿值，必填<br/>取值范围 -1 -- 1,可输入小数<br/>示例：0.52">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">报警阈值</label>
                                    <div class="layui-input-inline">
                                        <input type="number"  min="37.0" max="50.0"  step="0.1" name="parameterTempThresholdMax" autocomplete="off" class="layui-input"
                                               lay-verify="required" placeholder="请输入高温报警阈值" lay-reqText="请输入高温报警阈值"
                                               tipShow="1" tipMsg="高温报警阈值，必填<br/>取值范围 37 -- 50,可输入小数<br/>单位:摄氏度<br/>示例：37.6">
                                    </div>
                                </div>
    
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">华氏度</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterFahrenheitSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                </div>
                <!-- 网络参数 -->
                <div class="layui-tab-item" id="device_Update_Page4">
                    <fieldset class="table-search-fieldset">
                        <legend> 服务器参数</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label"> 服务器地址</label>
                                    <div class="layui-input-inline" style="width: 300px">
                                        <input type="text" maxlength="100" name="parameterCloudserverAddress" autocomplete="off" class="layui-input"
                                               lay-verify="required" placeholder="请输入服务器地址" lay-reqText="请输入服务器地址"
                                               tipShow="1" tipMsg="服务器地址，最长100个字符，必填<br/>示例：http://192.168.1.86:4610/FaceAPI">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 保活包间隔(秒)</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="7200" min="5" name="parameterPolling" autocomplete="off" class="layui-input"
                                               lay-verify="required" placeholder="请输入保活包发包间隔" lay-reqText="请输入保活包发包间隔"
                                               tipShow="1" tipMsg="保活包发包间隔，必填<br/>取值范围： 5 -- 7200，单位：秒">
                                    </div>
                                </div>

                            </div>

                        </div>

                    </fieldset>
                </div>

                <!-- 其他 -->
                <div class="layui-tab-item" id="device_Update_Page5">
                    <fieldset class="table-search-fieldset">
                        <legend> 记录存储</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label"> 存储陌生人记录</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterSaveExternalvisitors" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 保存现场图片</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterSavePicture" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>

                            </div>

                        </div>

                    </fieldset>
                </div>
            </div>

        </div>
    </div>
    <div class="layui-panel" style="text-align: center;" id="device_update_button_div">
        <style>
            #device_update_button_div button {
                width: 150px;
            }
        </style>
        <div style="margin: 5px 5px 5px 5px">
            <!-- 按钮 -->
            <div class="layui-form-item">
                <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-normal"
                            lay-submit lay-filter="data-save-btn">
                        <i class="layui-icon"></i> 保存
                    </button>
                </div>
                <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-danger"
                            id="data-cancel-btn">
                        <i class="layui-icon"></i> 取消
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use(['form', 'laydate', 'element', 'faceAPI'], function () {
        var element = layui.element;
        var form = layui.form;
        var laydate = layui.laydate, $ = layui.$;;
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        var faceAPI = layui.faceAPI;

        if (faceAPI.hasOwnProperty['DevicePageDefault'] == false) {
            layer.close(parentIndex);
            return;
        }

        if (faceAPI.DevicePageDefault == null) {
            layer.close(parentIndex);
            return;
        }
        //执行一个laydate实例
        laydate.render({
            elem: '[name="parameterProductionDate"]', //指定元素
            type: 'datetime'
        });

        //开始绑定字段值
        var d = faceAPI.DevicePageDefault;
        form.val("device_default_div_filter", d);

        //监听关闭
        $('#data-cancel-btn').on('click', function () {
            layer.close(parentIndex);
            return false;
        });


        //监听提交
        form.on('submit(data-save-btn)', function (data) {
            var postdata = data.field;
            //console.log(postdata);
            postdata.DeviceName = postdata.deviceID;
            postdata.parameterSerialNum = postdata.deviceID;
            faceAPI.Ajax({
                type: 'Post',
                data: postdata,
                url: '/api/FaceDevice/SetDefaultValue',
                success: function (result) {
                    if (result.result == false) {
                        layer.alert(result.error, { icon: 2 });
                    }
                    else {
                        layer.close(parentIndex);
                    }

                }
            });
            return false;
        });


        $("[lay-filter=device_default_div_filter] [tipShow=1]").mouseenter(input_mouseenter);
        $("[lay-filter=device_default_div_filter] [tipShow=1]").mouseleave(() => {
            if (iMouseenter_TipIndex > 0)
                layer.close(iMouseenter_TipIndex);
        });
        // 输入框 值范围提示
        var iMouseenter_TipIndex = 0;
        function input_mouseenter() {
            var that = this;
            if (iMouseenter_TipIndex > 0)
                layer.close(iMouseenter_TipIndex);
            var em = $(that);
            var msg = em.attr("tipMsg");

            iMouseenter_TipIndex = layer.tips(msg, that);
        }
    });
</script>
